//
//  BuyInfosTableViewCell.m
//  EasyBuy
//
//  Created by apple on 12-10-20.
//  Copyright (c) 2012年 shen donghao. All rights reserved.
//

#import "BuyInfosTableViewCell.h"

@implementation BuyInfosTableViewCell
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        // Initialization code
        buyInfoPriceSign = [[UILabel alloc] initWithFrame:CGRectMake(5,  0, 81, 26)];
        buyInfoPriceSign.backgroundColor = [UIColor clearColor];
        buyInfoPriceSign.font = [UIFont systemFontOfSize:15];
        buyInfoPriceSign.textColor = [UIColor whiteColor];
        buyInfoPriceSign.textAlignment = UITextAlignmentCenter;
        buyInfoPriceSign.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"buyInfo_PriceSign"]];
        [self addSubview:buyInfoPriceSign];
        [buyInfoPriceSign release];
        
        buyTime = [[UILabel alloc] initWithFrame:CGRectMake(170,0, 145, 40)];
        buyTime.textAlignment = UITextAlignmentRight;
        buyTime.font = [UIFont systemFontOfSize:15];
        buyTime.backgroundColor = [UIColor clearColor];
        buyTime.textColor = [UIColor grayColor];
        [self addSubview:buyTime];
        [buyTime release];
        
        UILabel *quality = [[UILabel alloc] initWithFrame:CGRectMake(15, 42, 40, 20)];
        quality.font = [UIFont systemFontOfSize:13];
        quality.backgroundColor = [UIColor clearColor];
        quality.text = @"成色 :";
        [self addSubview:quality];
        [quality release];
        
        qualityContent = [[UILabel alloc] initWithFrame:CGRectMake(50,  42, 200, 20)];
        qualityContent.font = [UIFont systemFontOfSize:13];
        qualityContent.backgroundColor = [UIColor clearColor];
        [self addSubview:qualityContent];
        [qualityContent release];
        
        UILabel *buyWay = [[UILabel alloc] initWithFrame:CGRectMake(15, quality.frame.origin.y + 25, 60, 20)];
        buyWay.backgroundColor = [UIColor clearColor];
        buyWay.font = [UIFont systemFontOfSize:13];
        buyWay.text = @"交易方式 :";
        [self addSubview:buyWay];
        [buyWay release];
        
        buyWayContent = [[UILabel alloc] initWithFrame:CGRectMake(80,quality.frame.origin.y + 25, 200, 20)];
        buyWayContent.font = [UIFont systemFontOfSize:13];
        buyWayContent.backgroundColor = [UIColor clearColor];
        [self addSubview:buyWayContent];
        [buyWayContent release];
        
        UILabel *carriage = [[UILabel alloc] initWithFrame:CGRectMake(15,buyWay.frame.origin.y +  25, 40, 20)];
        carriage.font = [UIFont systemFontOfSize:13];
        carriage.backgroundColor = [UIColor clearColor];
        carriage.text = @"运费 :";
        [self addSubview:carriage];
        [carriage release];
        
        carriageContent = [[UILabel alloc] initWithFrame:CGRectMake(50, buyWay.frame.origin.y + 25, 200, 20)];
        carriageContent.font = [UIFont systemFontOfSize:13];
        carriageContent.backgroundColor = [UIColor clearColor];
        [self addSubview:carriageContent];
        [carriageContent release];
        
        UILabel *address = [[UILabel alloc] initWithFrame:CGRectMake(15, carriage.frame.origin.y + 25, 40, 20)];
        address.font = [UIFont systemFontOfSize:13];
        address.backgroundColor = [UIColor clearColor];
        address.text = @"地址 :";
        [self addSubview:address];
        [address release];
        
        addressContent = [[UILabel alloc] initWithFrame:CGRectMake(50,carriage.frame.origin.y + 25, 200, 20)];
        addressContent.font = [UIFont systemFontOfSize:13];
        addressContent.backgroundColor = [UIColor clearColor];
        [self addSubview:addressContent];
        [addressContent release];
        
        buyInfoIntro = [[UILabel alloc] initWithFrame:CGRectMake(15,address.frame.origin.y+ 30, 290, 20)];
        buyInfoIntro.font = [UIFont systemFontOfSize:15];
        buyInfoIntro.backgroundColor = [UIColor clearColor];
        buyInfoIntro.textColor = [UIColor grayColor];
        [self addSubview:buyInfoIntro];
        [buyInfoIntro release];
        
        UILabel *buyInfoline2 = [[UILabel alloc]initWithFrame:CGRectMake(5,30, 310, 2)];
        buyInfoline2.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"buyInfo_line"]];
        [self addSubview:buyInfoline2];
        [buyInfoline2 release];

    }
    return self;
}

- (void)initCellWithBuyInfosData:(BuyInfoData *)buyInfoData{
    _buyInfoPrice = 880;
    _buyTime = @"2011.12.27";
    _quality = @"全新";
    _buyWay = @"当面／在线交易";
    _carriagePrice = 0;
    _address =@"北京 朝阳区";
    _buyInfoIntro =@"北京 朝阳区 大屯东路北88号北京 ";
    [self setInfoCellData];
}

- (void)setInfoCellData{
    buyInfoPriceSign.text = [NSString stringWithFormat:@"¥ %d",_buyInfoPrice];
    buyTime.text = _buyTime;
    qualityContent.text = _quality;
    buyWayContent.text = _buyWay;
    carriageContent.text = [NSString stringWithFormat:@"%d元",_carriagePrice];
    addressContent.text = _address;
    
    buyInfoIntro.text = _buyInfoIntro;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
